package ch03.test.test3_2;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
import org.apache.log4j.Logger;

import java.lang.reflect.Method;

public class Interptor implements MethodInterceptor {
    private Logger logger=Logger.getLogger(Interptor.class);
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        before();
        Object feedback=methodProxy.invokeSuper(o,objects);
        after();
        return "太棒了"+feedback;
    }
    public void before(){
        logger.debug("准备计算机。");
    }
    public void after(){
        logger.debug("计算完毕。");
    }
}
